import request from "@/utils/request";
import {DistrictItem, HospitalItem, HostTypeItem, PageHospital, PageParams} from "@/type/homeType";
import {Response} from "@/type/ResponseType";

enum Enum {
    fetchSearchListAPI = "/hosp/hospital/findByHosname",
    fetchHostTypeListAPI = "/cmn/dict/findByDictCode/Hostype",
    fetchDistrictsListAPI = "/cmn/dict/findByDictCode/Beijin",
    fetchHospitalListAPI = "/hosp/hospital"
}

/**
 *
 * @description 获取医院搜索列表的接口
 * */
export const fetchSearchListAPI = (query: string): Promise<Response<HospitalItem[]>> => request.get<HospitalItem[], Response<HospitalItem[]>>(`${Enum.fetchSearchListAPI}/${query}`);


/**
 *
 *@description 获取医院等级列表的接口
 * */
export const fetchHostTypeListAPI = () => request.get<HostTypeItem, Response<HostTypeItem[]>>(`${Enum.fetchHostTypeListAPI}`);


/**
 *
 * @description 获取北京的区县接口
 * */
export const fetchDistrictsListAPI = () => request.get<DistrictItem, Response<DistrictItem[]>>(`${Enum.fetchDistrictsListAPI}`)


/*
*
* 获取医院列表的接口
* */

export const fetchHospitalListAPI = (pageParams: PageParams) => request.get<PageHospital, Response<PageHospital>>(`${Enum.fetchHospitalListAPI}/${pageParams.page}/${pageParams.limit}`, {
    params: {
        hostype: pageParams.hostype,
        districtCode: pageParams.districtCode,
    }
});


